#pragma once

#include"Common.cpp"

//单列模式
class CentralCache
{
public:
    static CentralCache* GetInstance()//获取单例
    {
        return &_sInst;
    }
    size_t FetchRangeObj(void*& start,void*& end,size_t n,size_t size);//从CentralCache中获取n个大小为size的对象给thread cache
    Span* GetOneSpan(SpanList& spanList,size_t size);//获取一个非空的span
    void ReleaseListToSpans(void* start,size_t size);//将对象还给对应的span

private:
    SpanList _spanLists[NFREELISTS];//CentralCache的哈希表，每个SpanList对应一个哈希桶
private:
    CentralCache() {}//私有化构造函数
    CentralCache(const CentralCache&) = delete;//私有化拷贝构造函数
    static CentralCache _sInst;//单例指针
};